/*
	File:		EntityManager.h
	Course:		SGD 1301
	Author:		Peter Nguyen
	Purpose:	Stores & maintains game entities
*/

#pragma once

#include <list>
#include <hash_map>
#include <vector>
#include "..\SGD Wrappers\SGD_Math.h"

// Forward class declaration
class IEntity;
class CEntity;

////////////////////////////////////////////////////////////
// CEntityManager class
//	- contains & maintains game entities (Update, Render, etc)
class CEntityManager
{
public:
	////////////////////////////////////////////////////////
	// SINGLETON
	static CEntityManager*	GetInstance();
	static void				DeleteInstance();
	
	////////////////////////////////////////////////////////
	// Entity Management
	void	AddEntity	( IEntity* ptr );
	void	RemoveEntity( IEntity* ptr );
	void	RemoveAll	( void );

	void	UpdateAll	( float fElapsedTime );
	void	RenderAll	( void );

	void	CheckAllCollisions( void );

	void	LoadWayPoints(int _tileSize);

	unsigned int GetWayPointSize();

private:
	////////////////////////////////////////////////////////
	// SINGLETON
	static CEntityManager*	s_pInstance;
	CEntityManager(void);
	~CEntityManager(void);
	CEntityManager( const CEntityManager& );
	CEntityManager& operator= ( const CEntityManager& );

	////////////////////////////////////////////////////////
	// List of entities
	typedef std::list< IEntity* >	EntityList;		// 'easy' typename
		
	typedef std::hash_map< int,IEntity*>	EntityHashmap;		// 'easy' typename
	typedef std::pair<int,IEntity*> EntityHashPair;
	EntityList			m_lEntities;
	EntityList			m_lPowerUp;//used to update, not render
	EntityHashmap		m_hashTiles;
	bool				m_bIterating;
	
	///////////////////////////////////////////////////////
	// Waypoints
	std::vector<tVector2D> waypoints;
	int waypointMax;
public:
	tVector2D GetWayPoint(int &index);


};

